﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yunwei.BizLogic;
using Yunwei.Domain.Models;
using Yunwei.IBizLogic;

namespace Yunwei.Web.Models
{
    public class OrderFood
    {
        IOrderService _orderService;
        IFoodService _foodService;
        public OrderFood()
        {
            _orderService = new OrderService();
            _foodService = new FoodService();
        }
        public int Id { get; set; }
        public short Count { get; set; }
        public int Food_Id { get; set; }
        public int Order_Id { get; set; }

        public static OrderFood FromOrderFoodRel(OrderFoodRel ofr)
        {
            return new OrderFood()
            {
                Count = ofr.Count,
                Order_Id = ofr.Order_Id,
                Id = ofr.Id,
                Food_Id = ofr.Food_Id,
            };
        }

        public Food Food
        {
            get
            {
                return _foodService.Find(Food_Id);
            }
        }

        public Order Order
        {
            get
            {
                return _orderService.Find(Order_Id);
            }
        }
    }
}
